package com.gzz.orchid.context.domain.rbac;

import com.gzz.orchid.context.domain.rbac.entity.Privilege;
import com.gzz.orchid.context.domain.rbac.entity.UserDo;
import com.gzz.orchid.context.infrastructure.definition.Status;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.io.Serializable;
import java.util.List;

/**
 * @author higmd
 */
public interface IUserRepository {
    UserDo findByCode(String code);

    List<UserDo> findListByIds(Serializable[] ids);

    int batchDelete(Serializable[] ids);

    int batchChangeStatus(Status status, List<UserDo> doList);

    void save(UserDo userDo);

    void changePassword(UserDo userDo);

    /**
     * 保存特权权限
     */
    @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
    void saveGrantPrivilege(Long userId, List<Privilege> privileges);

    /**
     * 回收特权权限
     */
    @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
    void saveRecyclePrivilege(Long userId, List<Privilege> privileges);

}
